const array1 = [1, 2, 3, 4];
const reducer = (accumulator, currentValue) => accumulator + currentValue;

// 1 + 2 + 3 + 4
console.log(array1.reduce(reducer));
// expected output: 10

// 5 + 1 + 2 + 3 + 4
console.log(array1.reduce(reducer, 5));
// expected output: 15

console.log('***------------------------------');
console.log(array1.reduce(function (a) {
    console.log(a)
}))
console.log('&&&------------------------------');
console.log(array1.reduce(function (a, b) {
    console.log(a, b)
}));

console.log('&&&------------------------------');

let a = [0, 11, 22, 33, 44].reduce(function (accumulator, currentValue, currentIndex, array) {
    console.log(accumulator);
    console.log(currentValue);
    console.log(currentIndex);
    console.log(array);;
    console.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
    return accumulator + currentValue;
});
console.log(a);